//
//  ZitiViewCell.m
//  meizi
//
//  Created by zxin on 16/12/3.
//  Copyright © 2016年 deyi. All rights reserved.
//

#import "PublishTopicImageCell.h"

@implementation PublishTopicImageCell

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat width = (ScreenWidth - 24 - 24 * 3) / 4;
        if (!_icon) {
            _icon = [[UIImageView alloc] init];
            _icon.clipsToBounds = YES;
            _icon.frame = CGRectMake(0, 0, width, width);
            _icon.image = [UIImage imageNamed:@"post_Camera"];
            _icon.contentMode = UIViewContentModeScaleAspectFill;
            [self addSubview:_icon];
        }
        if (!_deletebtn) {
            _deletebtn = [UIButton buttonWithType:UIButtonTypeCustom];
            _deletebtn.frame = CGRectMake(width - 22 - 3, 3, 22, 22);
            [_deletebtn setBackgroundImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
            [_deletebtn addTarget:self action:@selector(clickDelete:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:_deletebtn];
            _deletebtn.hidden = YES;
        }
    }
    return self;
}

- (void)clickDelete:(UIButton *)button {
    if (self.delegate && [self.delegate respondsToSelector:@selector(publishTopicDeleteOne:)]) {
        [self.delegate publishTopicDeleteOne:self.indexPath];
    }
}

- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
}

@end
